# -*- coding: utf-8 -*-

################################################################################
## Form generated from reading UI file '使用滑块改变刻度值及标签中的字体大小.ui'
##
## Created by: Qt User Interface Compiler version 5.15.2
##
## WARNING! All changes made in this file will be lost when recompiling UI file!
################################################################################

from PySide2.QtCore import *
from PySide2.QtGui import *
from PySide2.QtWidgets import *
from PySide2 import QtGui, QtWidgets, QtCore
import sys


class Ui_MainWindow(object):
    def setupUi(self, MainWindow):
        if not MainWindow.objectName():
            MainWindow.setObjectName(u"MainWindow")
        MainWindow.resize(800, 600)
        self.centralwidget = QWidget(MainWindow)
        self.centralwidget.setObjectName(u"centralwidget")

        self.horizontalSlider = QSlider(self.centralwidget)
        self.horizontalSlider.setObjectName(u"horizontalSlider")
        self.horizontalSlider.setGeometry(QRect(190, 100, 301, 51))
        self.horizontalSlider.setOrientation(Qt.Horizontal)
        # 设置水平滑块的
        self.horizontalSlider.setMaximum(72)
        self.horizontalSlider.setMinimum(8)
        self.horizontalSlider.setPageStep(1)     # 设置通过鼠标点击时的步长值
        self.horizontalSlider.setSingleStep(1)   # 设置通过鼠标拖动时的步长值
        self.horizontalSlider.setProperty("value", 8)   # 设置默认值为8
        # 设置在滑块上方显示刻度
        self.horizontalSlider.setTickPosition(QtWidgets.QSlider.TicksAbove)
        self.horizontalSlider.setTickInterval(3)     # 设置刻度的间隔

        self.verticalSlider = QSlider(self.centralwidget)
        self.verticalSlider.setObjectName(u"verticalSlider")
        self.verticalSlider.setGeometry(QRect(580, 150, 61, 301))
        self.verticalSlider.setOrientation(Qt.Vertical)
        # 设置垂直滑块
        self.verticalSlider.setMaximum(72)
        self.verticalSlider.setMinimum(8)
        self.verticalSlider.setInvertedAppearance(True)     # 设置刻度反向显示
        # 设置刻度在右侧显示
        self.verticalSlider.setTickPosition(QtWidgets.QSlider.TicksRight)
        self.verticalSlider.setTickInterval(3)             # 设置刻度的间隔

        self.label = QLabel(self.centralwidget)
        self.label.setObjectName(u"label")
        self.label.setGeometry(QRect(230, 200, 291, 211))


        MainWindow.setCentralWidget(self.centralwidget)
        self.menubar = QMenuBar(MainWindow)
        self.menubar.setObjectName(u"menubar")
        self.menubar.setGeometry(QRect(0, 0, 800, 26))
        MainWindow.setMenuBar(self.menubar)
        self.statusbar = QStatusBar(MainWindow)
        self.statusbar.setObjectName(u"statusbar")
        MainWindow.setStatusBar(self.statusbar)

        self.retranslateUi(MainWindow)

        QMetaObject.connectSlotsByName(MainWindow)
        # 为水平滑块绑定信号与槽
        self.horizontalSlider.valueChanged.connect(self.setfontsize)

    # setupUi

    def retranslateUi(self, MainWindow):
        MainWindow.setWindowTitle(QCoreApplication.translate("MainWindow", u"\u4f7f\u7528\u6ed1\u5757\u6539\u53d8\u523b\u5ea6\u503c\u53ca\u6807\u7b7e\u4e2d\u7684\u6587\u5b57\u5927\u5c0f", None))
        self.label.setText(QCoreApplication.translate("MainWindow", u"\u6562\u60f3\u6562\u5e72\uff0c\u6ce8\u610f\u7ec6\u8282", None))
    # retranslateUi
    # 定义改变字体大小的槽函数
    def setfontsize(self):
        value = self.horizontalSlider.value()
        self.verticalSlider.setValue(value)
        self.label.setFont(QtGui.QFont("楷体", value))


if __name__ == '__main__':
    app = QtWidgets.QApplication(sys.argv)
    MainWindow = QtWidgets.QMainWindow()
    ui = Ui_MainWindow()
    ui.setupUi(MainWindow)
    MainWindow.show()
    sys.exit(app.exec_())

